package com.situ.pattern.singleton;

public class Singleton5 {
    // static Singleton5 INSTANCE = new Singleton5();

    private Singleton5() {
        System.out.println("Singleton5.Singleton5");
    }

    private static class Holder {
        // 会放到静态代码块中执行，静态代码块里面的线程安全由虚拟机来保证
        static Singleton5 INSTANCE = new Singleton5();
    }

    public static Singleton5 getInstance() {
        System.out.println("Singleton5.getInstance");
        return Holder.INSTANCE;
    }

    public static void test() {
        System.out.println("Singleton5.test");
    }
}
